package info.qingshui.browser.hk.index;



@SuppressWarnings("rawtypes")
public class URLInfo implements Comparable, java.io.Serializable{
	
	private static final long serialVersionUID = 9116206809191449666L;
	
	private String type = "";//网站类型 
	private String url = "";
	private String title = "";
	private String des = " ";
	private String order;
	
	private String imgPath = "d.png";
	private int clickCount;//点击次数
	
	public URLInfo() {
	}
	
	public boolean isGoodURL() {
		return ( null != url && !"".equals(url));
	}
	
	public void addClickCount() {
		clickCount ++;
	}
	
	public URLInfo(int id, String title, String url, String imgPath) {
		super();
		this.title = title;
		this.url = url;
		this.imgPath = imgPath;
	}
	public URLInfo(int id,String title, String url, String imgPath,String des) {
		super();
		this.title = title;
		this.url = url;
		this.imgPath = imgPath;
		this.des = des;
	}
	
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getImgPath() {
		return  imgPath;
	}
	public void setImgPath(String imgPath) {
		if ( imgPath != null && ! "".equals( imgPath )) {
			this.imgPath = imgPath;
		} 
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getDes() {
		return des;
	}
	public void setDes(String des) {
		this.des = des;
	}

	
//	public String  getBaiduURL() {
//		return Setting.BAIDU_PROXY + this.url.replaceAll("&", "&amp;");
//	}
//	
//	public String getGoogleURL() {
//		return Setting.GOOGLE_PROXY +  this.url.replaceAll("&", "&amp;");
//	}

	public int getOrder() {
		try {
			return Integer.parseInt(order);
		} catch (NumberFormatException e) {
			return 0;
		}
	}

	public void setOrder(String order) {
		this.order = order;
	}

	public int getClickCount() {
		return clickCount;
	}

	public void setClickCount(int clickCount) {
		this.clickCount = clickCount;
	}
	
	@Override 
	//先按clickCount排序，然后按order排序
	public int compareTo(Object another) {
		URLInfo a = (URLInfo)another;
		if ( this.getClickCount() < a.getClickCount() ) {
			return 1;
		} else if ( this.getClickCount() == a.getClickCount() ) {
			if ( this.getOrder() < a.getOrder()  ) {
				return 1;
			} else if ( this.getOrder() ==  a.getOrder()  ) {
				return 0;
			}
		}
		
		return -1;
	}
	
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String toString() {
		return this.url + "=" + this.clickCount;
	}
	
	public boolean isHongKong( ) {
		return "香港".equals(this.type);
	}
	public boolean isChina( ) {
		return "大陆".equals(this.type);
	}
	public boolean isTaiwan( ) {
		return "台湾".equals(this.type);
	}
	public boolean isHaiwai( ) {
		return "海外".equals(this.type);
	}
	public boolean isOthers( ) {
		return "其他".equals(this.type);
	}
	
	
}
